#!/bin/csh

setenv HPBCGHOME %%HOME%%
setenv D ${HPBCGHOME}/share/java
if (! -e ${D}/HPBCG.jar) then
    echo "Installation problem. HPBCG.jar is missing"
    echo "Please build HPBCG.jar"
    exit
endif

setenv CLASSPATH ${D}/HPBCG.jar:${D}/antlr-3.1.1-runtime.jar:$CLASSPATH
# echo $CLASSPATH

foreach P (java gij)
    foreach D (/opt/ibm/java-ppc-60/bin/ /home/hpc/bin /usr/local/bin/ /usr/bin/)
	# echo $D/$P
	if (-e $D/$P) then
	    setenv JAVA $D/$P
	    break
	endif
    end
    if ($?JAVA) break
end
# echo "--" $JAVA
if (! $?JAVA) then
    echo "Please provide a runnable jdk"
    exit
endif

${JAVA} -DHPBCGHOME=$HPBCGHOME org.hpbcg.Main $*
